﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Globalization;
using System.Threading;
using GAE_PI.Models;
using GAE_PI.Exceptions;

namespace GAE_PI.Controllers
{
    public class NouveauCatalogueController : Controller
    {
        public ActionResult NouveauCatalogue()
        {
            if (!DBModel.getDBM().isAdmin())
                return RedirectToAction("ConsulterActivites", "ConsulterActivites");

            return View(new Catalogue());
        }

        [HttpPost]
        public ActionResult NouveauCatalogue(Catalogue c)
        {
            try
            {
                DBModel.getDBM().nouveauCatalogue(c);
            }
            catch (GAEException ex)
            {
                ex.errorModel.ControllerName = "NouveauCatalogue";
                ex.errorModel.ControllerAction = "NouveauCatalogue";
                return View("Error", ex.errorModel);
            }
            return RedirectToAction("ConsulterActivites", "ConsulterActivites");
        }

    }
}